﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using App.Data;
using App.Domain.Contracts;

namespace App.Domain.Handlers
{
    public class UpdateRecruiterChangePwd
    {
        private readonly IRecruiterRepository _recruiterRepository;

        public UpdateRecruiterChangePwd(IRecruiterRepository recruiterRepository)
        {
            _recruiterRepository = recruiterRepository;
        }

        public void Execute(Guid UserId, string Pwd)
        {
            try
            {
                var recruiter = _recruiterRepository.GetRecruiter(UserId);
                recruiter.Password = Pwd;

                _recruiterRepository.Update(recruiter);
            }
            catch (InvalidOperationException ex)
            {
                throw new BusinessServicesException("CannotFindVehicleToUpdateExceptionMessage", ex);
            }
        }

    }
}
